﻿using System.Web;
using LCL.Business;
using LCL.Common;
using LCL.MVC;
using NVelocity;
using LCL.Config;


namespace LCL
{
    public class login : IHandlerFactory
    {
        /// <summary>
        /// 页面提交
        /// </summary>
        /// <param name="cxt"></param>
        public  void Page_PostBack(ref VelocityContext cxt)
        {
            string username =Input.GetString("uname");
            string password = Input.GetString("pwd");
            string url=Input.GetString("url");
            if (Users.Login(username, password, false))
            {
                if (url == "")//如果没有保存路径，跳转到首页
                {
                    cxt.Put("redirecturl", cxt.Get("webpath") + "/index" + UiConfig.ExName);
                }
                else
                {
                    cxt.Put("redirecturl", url);
                }
            }
            else
            {
                HttpContext.Current.Response.Write("登陆失败");
                HttpContext.Current.Response.End();
            } 
        }

        public void Page_Load(ref VelocityContext context)
        {
          
        }
    }
}